package org.example.mynote.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.mynote.Entity.Note;

import java.util.List;
import java.util.Optional;

@Mapper
public interface FavoriteMapper {

    // 添加收藏
    int insert(@Param("userId") Long userId, @Param("noteId") Long noteId);

    // 取消收藏
    int delete(@Param("userId") Long userId, @Param("noteId") Long noteId);

    // 检查某用户是否收藏了某笔记
    Optional<Long> findByUserIdAndNoteId(@Param("userId") Long userId, @Param("noteId") Long noteId);

    // 获取某用户收藏的所有笔记
    List<Note> findFavoriteNotesByUserId(Long userId);
}
